package edu.gdit.health;

import edu.gdit.health.dao.SysReportDao;
import edu.gdit.health.dao.SysUserDao;
import edu.gdit.health.model.SysReport;
import edu.gdit.health.model.SysUser;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

@SpringBootTest
class HealthApplicationTests {
    //自动注入 sysReportDao 到当前运行环境内
    @Autowired
    SysReportDao sysReportDao;
    SysUserDao sysUserDao;
//SysReport
    @Test
    public void contextLoads() {
        System.out.println("contextLoads...");
    }
    @Test
    public void testReportGetAll() {
        System.out.println("testReportGetAll...");
        sysReportDao.getAll().stream().forEach(System.out::println);
//        System.out.println("=======================");
//        //展开式子
//        sysReportDao.getAll().stream().forEach(item ->{
//            System.out.println(item);
//        });
//        System.out.println("=======================");
        //迭代
//        for (SysReport sysReport : sysReportDao.getAll()){
//            System.out.println(sysReport);
//        }

    }
    @Test
    public void testReportGetById(){
        System.out.println("testReportGetById...");
        SysReport sysReport=sysReportDao.getById(34);
        System.out.println(sysReport);

    }
    @Test
    public void testReportSave(){
        System.out.println("testReportSave...");
        SysReport sysReport=new SysReport();
        sysReport.setUserId(1L);
        sysReport.setTemperature("NORMAL");
        sysReport.setTravel(0L);
        sysReport.setPhysicalCondition("normal");
        sysReport.setRemark("Lemon test data2");
        sysReportDao.save(sysReport);
        System.out.println(sysReport.getId());
    }
    @Test
    public void testReportDelete(){
        System.out.println("testReportDelete...");
        System.out.println(sysReportDao.delete(44));
    }
    @Test
    public void testReportUpdate(){
        System.out.println("testReportUpdate...");
        SysReport sysReport= sysReportDao.getById(36);
        System.out.println(sysReport);
        sysReport.setRemark("Lemon update 1");
        sysReportDao.update(sysReport);
        System.out.println(sysReport);
    }

    @Test
    public void testGetAddSysReport(){
        System.out.println("test save");
        SysReport sysReport = new SysReport();
        sysReport.setId(1L);
        sysReport.setRemark("阿伟");
        sysReportDao.save(sysReport);
    }
//SysUser
//@Test
//public void testUserGetAll() {
//    System.out.println("testUserGetAll...");
//    sysUserDao.getAll().stream().forEach(System.out::println);
//}
//    @Test
//    public void testUserGetById(){
//        System.out.println("testUserGetById...");
//        SysUser sysUser=sysUserDao.getById(30);
//        System.out.println(sysUser.getNickname());
//    }

}
